﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class ModifierDossierForm : Form
    {

        private Dossier_incomplet di = new Dossier_incomplet();

        public Dossier_incomplet Di
        {
            get { return di; }
            set { di = value; }
        }

        public RechercheDossierFormcs Recherchedossierform { get; set; }


        public ModifierDossierForm()
        {
            InitializeComponent();
            RAMEDEntities1 context = SingletonContext.GetContext();
            comboBoxannexe.DataSource = context.Annexe_administratif;
            comboBoxannexe.DisplayMember = "nom_annexe_administratif";
            comboBoxannexe.ValueMember = "id_annexe_administratif";
          
        }

        private void btnmodifierrincompler_Click(object sender, EventArgs e)
        {

            RAMEDEntities1 Context = SingletonContext.GetContext();
            Dossier_incomplet di = new Dossier_incomplet();
            di = Context.Dossier_incomplet.Where(d => d.id_dossier_incomplet == Di.id_dossier_incomplet).First();
            di.num_dossier = utitlitaire.CasterString(txtnumdoss.Text);
            di.champs_manquent = txtchamps.Text;
            di.Nom = txtnom.Text;
            di.Prenom = txtprenom.Text;
            di.CIN = txtCIN.Text;
            di.id_annexe_administratif = ((Annexe_administratif)comboBoxannexe.SelectedItem ).id_annexe_administratif;
            Recherchedossierform.mettreAjourFormGridView();

            Context.SaveChanges();
            this.Dispose();
           

        }

        public void InitialiserChamps()
        {
            txtnumdoss.Text = di.num_dossier.ToString();
            txtchamps.Text = di.champs_manquent; txtnom.Text = di.Nom;
            txtprenom.Text = di.Prenom;
            txtCIN.Text = di.CIN;

            
            comboBoxannexe.SelectedValue = di.Annexe_administratif.id_annexe_administratif;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
       

        private void ModifierDossierForm_Load(object sender, EventArgs e)
        {

        }
      
    }
}
